home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group98b.txt
/
000095_icon-group-sender _Fri Jun 19 12:38:33 1998.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
5KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.8.8/8.8.7) with SMTP id MAA22247
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Fri, 19 Jun 1998 12:38:33 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA28231; Fri, 19 Jun 1998 12:38:23 -0700
To: icon-group@optima.CS.Arizona.EDU
Date: 19 Jun 1998 13:30:56 GMT
From: cdt@post.its.mcw.edu (Chris Tenaglia)
Message-Id: <6mdp6g$k4g@wiscnews.wiscnet.net>
Organization: Medical College of Wisconsin - Milwaukee, WI
Sender: icon-group-request@optima.CS.Arizona.EDU
Subject: CGI progress
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Content-Length: 4413
Finally, some progress. Maybe its not the optimal approach,
but given this particular unix environment it can be made
to work well. Here's a summary ...
1. CGI program outputs Content-Type: text/html and a blank line.
2. The output is good HTML
3. The GET method is needed to accept data from a form.
4. There are useful environment variables.
This is where the input data can be found.
Icon can parse it quite easily.
5. icont and iconx installed in the CGI directory
6. I used a frontend to run the cgi program. This is because
we did not have a C compiler to use iconc to make pure
executables. So then the url looks like cgi-bin/iconx?program...
and it seemed like parameters/variables beyond 'program'
where not reachable.
###################################################################
#
# file : docgi.icn
# desc : this program is a cgi learning experiment
# use : called by cgi in the web server
#
# update by what
# 08-jun-1998 tenaglia initial write
#
global nvp # name-value table
procedure main(param)
query := getenv("QUERY_STRING") | "interactive"
method:= getenv("REQUEST_METHOD") | "interactive"
path := getenv("PATH_INFO") | "unknown"
remote:= getenv("REMOTE_USER") | "unknown"
adrs := getenv("REMOTE_ADDR") | "interactive"
log := open("/db1/local/httpd/cgi-bin/bioet/docgi.log","a")
write(log,adrs," Accessed DOCGI at ",&dateline," with ",query)
close(log)
fi := open("/db1/local/httpd/cgi-bin/bioet/docgi.cnt")
bump := read(fi) + 1
close(fi)
fo := open("/db1/local/httpd/cgi-bin/bioet/docgi.cnt","w")
write(fo,bump)
close(fo)
nvp := table("n/a")
parts := parse(query,'&')
every part := !parts do
{
pair := parse(part,'=')
ident := unurl(pair[1])
value := unurl(pair[2])
nvp[ident] := value
}
write("Content-type: text/html")
write("")
write("<HTML>")
write("<HEAD>")
write("<TITLE>This is the CGI Generated Title</TITLE>")
write("</HEAD>")
write("<BODY>")
write("<BODY BGCOLOR=#FFFFFF>")
write("<H1>Big Header</H1>")
write("<P><P><P>")
write("Here's a crazy web page!<P>")
write("The parameter was :",param[1],"<P>")
write("The query string var is :",query,"<P>")
write("<TABLE border=5>")
write("<TH>Name Parts</TH><TH>Value Parts</TH>")
write("<TR><TD>NAME</TD><TD>VALUE</TD></TR>")
every xxx := key(nvp) do
{
write("<TR><TD>",xxx,"</TD><TD>",nvp[xxx],"</TD></TR>")
}
write("</TABLE>")
write("<P>")
write("<P>")
write("<TABLE BORDER=10>")
write("<TH>CGI Parameters</TH><TH>CGI Values</TH>")
write("<TR><TD>Method</TD><TD>",method,"</TD></TR>")
write("<TR><TD>Path</TD><TD>",path,"</TD></TR>")
write("<TR><TD>Username</TD><TD>",remote,"</TD</TR>")
write("<TR><TD>Remote address</TD><TD>",adrs,"</TD></TR>")
write("<TR><TD>Page counter</TD><TD>",bump,"</TD></TR>")
write("</TABLE>")
write("</BODY>")
write("</HTML>")
end
#
# parse a string into a list with respect to a delimiter
#
procedure parse(line,delims)
static chars
chars := &cset -- delims
tokens := []
line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
return tokens
end
#
# This procedure maps the wierd characters out of cgi query strings
#
procedure unurl(text)
static hex
initial {
hex := table("")
hex["0"] := 0 ; hex["1"] := 1 ; hex["2"] := 2 ; hex["3"] := 3
hex["4"] := 4 ; hex["5"] := 5 ; hex["6"] := 6 ; hex["7"] := 7
hex["8"] := 8 ; hex["9"] := 9 ; hex["a"] := 10; hex["A"] := 10
hex["b"] := 11; hex["B"] := 11; hex["c"] := 12; hex["C"] := 12
hex["d"] := 13; hex["D"] := 13; hex["e"] := 14; hex["e"] := 14
hex["f"] := 15; hex["F"] := 15
}
work := map(text,"+"," ")
cache := []
every i := 1 to *work do if work[i] == "%" then put(cache,i)
while i := pop(cache) do
{
nyb1 := work[i+1]
nyb2 := work[i+2]
if (nyb1 == "") | (nyb2 == "") then next
raw := hex[nyb1] * 16 + hex[nyb2]
byte := char(raw)
work[i+:3] := byte
}
return work
end
###################################################################
--
Chris Tenaglia (system manager) | The future foretold,
Medical College of Wisconsin | The past explained,
8701 W. Watertown Plank Rd. | The present largely appologized for.
Milwaukee, WI 53226 (414)456-8765 | Organon to the Doctor